1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module sourceview.File;
26 
27 private import gio.FileIF;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import sourceview.Encoding;
31 private import sourceview.c.functions;
32 public  import sourceview.c.types;
33 
34 
35 /**
36  * On-disk representation of a [class@Buffer].
37  * 
38  * A `GtkSourceFile` object is the on-disk representation of a [class@Buffer].
39  * With a `GtkSourceFile`, you can create and configure a [class@FileLoader]
40  * and [class@FileSaver] which take by default the values of the
41  * `GtkSourceFile` properties (except for the file loader which auto-detect some
42  * properties). On a successful load or save operation, the `GtkSourceFile`
43  * properties are updated. If an operation fails, the `GtkSourceFile` properties
44  * have still the previous valid values.
45  */
46 public class File : ObjectG
47 {
48 	/** the main Gtk struct */
49 	protected GtkSourceFile* gtkSourceFile;
50 
51 	/** Get the main Gtk struct */
52 	public GtkSourceFile* getFileStruct(bool transferOwnership = false)
53 	{
54 		if (transferOwnership)
55 			ownedRef = false;
56 		return gtkSourceFile;
57 	}
58 
59 	/** the main Gtk struct as a void* */
60 	protected override void* getStruct()
61 	{
62 		return cast(void*)gtkSourceFile;
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GtkSourceFile* gtkSourceFile, bool ownedRef = false)
69 	{
70 		this.gtkSourceFile = gtkSourceFile;
71 		super(cast(GObject*)gtkSourceFile, ownedRef);
72 	}
73 
74 
75 	/** */
76 	public static GType getType()
77 	{
78 		return gtk_source_file_get_type();
79 	}
80 
81 	/**
82 	 * Returns: a new #GtkSourceFile object.
83 	 *
84 	 * Throws: ConstructionException GTK+ fails to create the object.
85 	 */
86 	public this()
87 	{
88 		auto __p = gtk_source_file_new();
89 
90 		if(__p is null)
91 		{
92 			throw new ConstructionException("null returned by new");
93 		}
94 
95 		this(cast(GtkSourceFile*) __p, true);
96 	}
97 
98 	/**
99 	 * Checks synchronously the file on disk, to know whether the file is externally
100 	 * modified, or has been deleted, and whether the file is read-only.
101 	 *
102 	 * #GtkSourceFile doesn't create a [class@Gio.FileMonitor] to track those properties, so
103 	 * this function needs to be called instead. Creating lots of [class@Gio.FileMonitor]'s
104 	 * would take lots of resources.
105 	 *
106 	 * Since this function is synchronous, it is advised to call it only on local
107 	 * files. See [method@File.is_local].
108 	 */
109 	public void checkFileOnDisk()
110 	{
111 		gtk_source_file_check_file_on_disk(gtkSourceFile);
112 	}
113 
114 	/**
115 	 * Returns: the compression type.
116 	 */
117 	public GtkSourceCompressionType getCompressionType()
118 	{
119 		return gtk_source_file_get_compression_type(gtkSourceFile);
120 	}
121 
122 	/**
123 	 * The encoding is initially %NULL. After a successful file loading or saving
124 	 * operation, the encoding is non-%NULL.
125 	 *
126 	 * Returns: the character encoding.
127 	 */
128 	public Encoding getEncoding()
129 	{
130 		auto __p = gtk_source_file_get_encoding(gtkSourceFile);
131 
132 		if(__p is null)
133 		{
134 			return null;
135 		}
136 
137 		return ObjectG.getDObject!(Encoding)(cast(GtkSourceEncoding*) __p);
138 	}
139 
140 	/**
141 	 * Returns: the #GFile.
142 	 */
143 	public FileIF getLocation()
144 	{
145 		auto __p = gtk_source_file_get_location(gtkSourceFile);
146 
147 		if(__p is null)
148 		{
149 			return null;
150 		}
151 
152 		return ObjectG.getDObject!(FileIF)(cast(GFile*) __p);
153 	}
154 
155 	/**
156 	 * Returns: the newline type.
157 	 */
158 	public GtkSourceNewlineType getNewlineType()
159 	{
160 		return gtk_source_file_get_newline_type(gtkSourceFile);
161 	}
162 
163 	/**
164 	 * Returns whether the file has been deleted. If the
165 	 * [property@File:location] is %NULL, returns %FALSE.
166 	 *
167 	 * To have an up-to-date value, you must first call
168 	 * [method@File.check_file_on_disk].
169 	 *
170 	 * Returns: whether the file has been deleted.
171 	 */
172 	public bool isDeleted()
173 	{
174 		return gtk_source_file_is_deleted(gtkSourceFile) != 0;
175 	}
176 
177 	/**
178 	 * Returns whether the file is externally modified. If the
179 	 * [property@File:location] is %NULL, returns %FALSE.
180 	 *
181 	 * To have an up-to-date value, you must first call
182 	 * [method@File.check_file_on_disk].
183 	 *
184 	 * Returns: whether the file is externally modified.
185 	 */
186 	public bool isExternallyModified()
187 	{
188 		return gtk_source_file_is_externally_modified(gtkSourceFile) != 0;
189 	}
190 
191 	/**
192 	 * Returns whether the file is local. If the [property@File:location] is %NULL,
193 	 * returns %FALSE.
194 	 *
195 	 * Returns: whether the file is local.
196 	 */
197 	public bool isLocal()
198 	{
199 		return gtk_source_file_is_local(gtkSourceFile) != 0;
200 	}
201 
202 	/**
203 	 * Returns whether the file is read-only. If the
204 	 * [property@File:location] is %NULL, returns %FALSE.
205 	 *
206 	 * To have an up-to-date value, you must first call
207 	 * [method@File.check_file_on_disk].
208 	 *
209 	 * Returns: whether the file is read-only.
210 	 */
211 	public bool isReadonly()
212 	{
213 		return gtk_source_file_is_readonly(gtkSourceFile) != 0;
214 	}
215 
216 	/**
217 	 * Sets the location.
218 	 *
219 	 * Params:
220 	 *     location = the new #GFile, or %NULL.
221 	 */
222 	public void setLocation(FileIF location)
223 	{
224 		gtk_source_file_set_location(gtkSourceFile, (location is null) ? null : location.getFileStruct());
225 	}
226 
227 	/**
228 	 * Sets a [callback@MountOperationFactory] function that will be called when a
229 	 * [class@Gio.MountOperation] must be created.
230 	 *
231 	 * This is useful for creating a [class@Gtk.MountOperation] with the parent [class@Gtk.Window].
232 	 *
233 	 * If a mount operation factory isn't set, [ctor@Gio.MountOperation.new] will be
234 	 * called.
235 	 *
236 	 * Params:
237 	 *     callback = a #GtkSourceMountOperationFactory to call when a
238 	 *         #GMountOperation is needed.
239 	 *     userData = the data to pass to the @callback function.
240 	 *     notify = function to call on @user_data when the @callback is no
241 	 *         longer needed, or %NULL.
242 	 */
243 	public void setMountOperationFactory(GtkSourceMountOperationFactory callback, void* userData, GDestroyNotify notify)
244 	{
245 		gtk_source_file_set_mount_operation_factory(gtkSourceFile, callback, userData, notify);
246 	}
247 }